NOTES
This problem is a simple, three-loop problem with slightly more complicated glue code (e.g. shifting down to the red square from the row above).
Give the students opportunities to discuss the problem and map it out with a partner.
Show how each stage of the problem can be tested before moving on to the next stage.
Observe how starting on a red square colludes with a color-based loop condition, requiring that bit move of the square first. Or (as done in the solution), you can simply use bit.front_clear()
.
Explain that an important skill in programming is identifying the technical requirements of a problem. Often, when the problem is simple, the solution can be simple. If the problem changes to become more complex, the code will need to change also. Comparing across instances of a problem helps us understand the nature of the problem and decide how complicated the code needs to be.
For example, if one of the bridges had an empty space immediately after the bridge, bit.front_clear()
would not work, and you'd have to use a color-based loop condition. Add fix-different-bridge
to the script to demonstrate.
Talk through how the code needs to change to adapt to this new requirement.
The next two problems introduce the important concept of nested loops, so don't spend too much time on this one (maybe 10-15 minutes, leaving more time for the other problem).